package com.sywb.chuangyebao.contract;

import com.sywb.chuangyebao.Constants;
import com.sywb.chuangyebao.bean.UserInfo;
import com.sywb.chuangyebao.utils.HttpUtils;
import com.umeng.analytics.MobclickAgent;

import org.bining.footstone.utils.SharedUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 开始界面的Contract
 */
public interface RegisterContract {

    /**
     * 开始界面要实现的View
     */
    interface View extends BaseTokenContract.View {
    }

    /**
     * 开始界面要绑定的Presenter
     */
    class Presenter extends BaseTokenContract.Presenter<View> {

        @Override
        public void onStart() {
            super.onStart();
        }

        public void register(String mobile, String password, String code) {
            SharedUtils.put(Constants.USERACCOUNT, mobile);
            SharedUtils.put(Constants.USERPASSWORD, password);
            SharedUtils.put(Constants.USERCAPTCHA, code);
            HttpUtils.signup(getTokenCallback());
        }

        @Override
        protected void afterLogin(UserInfo mobile) {
            super.afterLogin(mobile);
            Map regMap = new HashMap();
            regMap.put("userid", mobile.uid);
            MobclickAgent.onEvent(mContext, "__register", regMap);
        }
    }
}

